<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : XMLTransformation1.xsl
    Created on : 23 novembre 2013, 18:34
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="html"/>
    
  <xsl:output method="html" encoding="UTF-8" name="html"/>

    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:template match="/emploisdutemps">
        
        <xsl:for-each-group select="//cours" group-by="parcours">
        
        <xsl:variable name="p">
            <xsl:value-of select="current-grouping-key()"/>
        </xsl:variable>
        <xsl:result-document format="html" encoding="UTF-8" href="web\ressources\html\{$p}.htm">
            <html>
            <head>
                <title>Premiere transformation xslt</title>
            </head>
            <body>
                <h1>Parcours <xsl:value-of select="$p"/></h1>
                <table border="1">
                    <tr>
                        <th>Date</th>
                        <th>Horaire</th>
                        <th>Cours</th>
                        <th>Enseigant</th>
                        <th>localisation</th>
                    </tr>
                    <xsl:for-each select="//cours[parcours=$p]">
                        <xsl:sort select="datedebut/annee"/>
                        <xsl:sort select="datedebut/mois"/>
                        <xsl:sort select="datedebut/jour"/>
                        <xsl:sort select="datedebut/heure"/>
                        <xsl:sort select="datedebut/minute"/>
                        <tr>
                            <td>
                                    
                                <xsl:value-of select="concat(datedebut/jour,'/',datedebut/mois,'/',datedebut/annee)"/>
                            </td>
                            <td>
                                <xsl:value-of select="datedebut/heure"/>:
                                <xsl:value-of select="datedebut/minute"/> - 
                                <xsl:value-of select="datefin/heure"/>:
                                <xsl:value-of select="datefin/minute"/>
                            </td>
                            <td>
                                <xsl:value-of select="resume"/>
                            </td>
                            <td>
                                <xsl:value-of select="@enseignant"/>
                            </td>
                            <td>
                                <xsl:value-of select="location"/>
                            </td>
                           
                        </tr> 
                        
                        
                    </xsl:for-each>                  
               
               
                </table>
            </body>
        </html>
        </xsl:result-document>
        </xsl:for-each-group>
    </xsl:template>

</xsl:stylesheet>
